<?php
namespace BigVideo\Other\Observer;

/**
 * 是具体的目标对象，负责把有关状态存入到相应的观察者对象中
 * Class ConcreteSubject
 * @package BigVideo\Other\Observer
 */
class ConcreteWeatherSubject extends WeatherSubject
{
    private $weatherContent;

    /**
     * @param mixed $weatherContent
     */
    public function setWeatherContent($weatherContent)
    {
        $this->weatherContent = $weatherContent;
        $this->notifyObserver();//通知所有人
    }

    /**
     * @return mixed
     */
    public function getWeatherContent()
    {
        return $this->weatherContent;
    }

    protected function notifyObserver()
    {
        /** @var Observer $observer */
        foreach ($this->subjectList as $observer){
            if($this->getWeatherContent()=="下雨") $observer->update($this);

            if($this->getWeatherContent()=="下雪" and $observer->getName()=='xiaominglaoma')$observer->update($this);
        }
    }

}










